package com.bytedance.common.plugin.interfaces.pushmanager.setting;

import android.content.Context;
import android.support.design.a;

import com.bytedance.common.plugin.interfaces.pushmanager.PushCommonConstants;
import com.bytedance.common.plugin.interfaces.pushmanager.setting.PushMultiProcessSharedProvider.MultiProcessShared;
import com.bytedance.common.utility.Logger;

import java.util.HashMap;
import java.util.Map;

public class PushCommonSetting {
    public static final String SSIDS = "ssids";
    private Context mContext;
    private MultiProcessShared multiProcessShared;
    private static PushCommonSetting sPushSetting;

    private PushCommonSetting(Context arg2) {
        this.mContext = arg2.getApplicationContext();
        this.multiProcessShared = PushMultiProcessSharedProvider.getMultiprocessShared(this.mContext);
    }

    public String getDeviceId() {
        HashMap v0 = new HashMap();
        this.getSSIDs(((Map) v0));
        return (String) ((Map) v0).get(PushCommonConstants.KEY_DEVICE_ID);
    }

    public static PushCommonSetting getInstance() {
        PushCommonSetting v0_1;
        Class v1 = PushCommonSetting.class;
        synchronized (v1) {
            if (PushCommonSetting.sPushSetting == null) {
                throw new IllegalStateException("PushSetting not init");
            }

            v0_1 = PushCommonSetting.sPushSetting;
        }
        return v0_1;
    }

    public void getSSIDs(Map arg3) {
        if (arg3 != null) {
            if (Logger.debug()) {
                Logger.d("PushService", "getSSIDs start");
            }

            try {
                String v0_1 = this.getSsids();
                if (a.isTextEmpty(v0_1)) {
                    return;
                }
                a.a(v0_1, arg3);
            } catch (Exception v0) {
            }
        }
    }

    public String getSsids() {
        return this.multiProcessShared.getString("ssids", "");
    }

    public static void init(Context arg2) {
        Class v1 = PushCommonSetting.class;
        synchronized (v1){
            if (PushCommonSetting.sPushSetting == null) {
                PushCommonSetting.sPushSetting = new PushCommonSetting(arg2);
            }
        }
    }

    public void saveSSIDs(Map arg4) {
        if (arg4 != null) {
            if (Logger.debug()) {
                Logger.d("PushService", "saveSSIDs start");
            }

            try {
                this.multiProcessShared.edit().putString("ssids", a.a(arg4)).apply();
            } catch (Exception v0) {
            }
        }
    }
}

